package servlet3;

import com.google.gson.Gson;
import dao.DB;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


//删除好友
@WebServlet("/deleteFrirnd")
public class deleteFrirnd extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String acc = req.getParameter("acc");
        String uid = req.getParameter("uid");

       int tmp = DB.executeUpdate("DELETE FROM friend WHERE userid= "+uid+"  and friendid = "+acc+" or userid= "+acc+"  and friendid = "+uid+"");
       int tmp1=  DB.executeUpdate("DELETE FROM pagenotes WHERE Tuid=?  and Tfid = ?  ",acc,uid);
       int tmp2=  DB.executeUpdate("DELETE FROM pagenotes WHERE Tuid=?  and Tfid = ?  ",uid,acc);



        resp.getWriter().print(new Gson().toJson(tmp1));

    }
}
